package cn.ddiancan.xddcloud.psc.flow.feign;

import java.util.List;
import java.util.Optional;

import cn.ddiancan.xddcloud.psc.flow.entity.XddInstance;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 流程实例数据访问层接口
 */
@FeignClient(contextId = "XddInstanceService", name = "xddcloud-flow-server")
public interface XddInstanceRemoteService {

    @PostMapping("/flow/instance/insert")
    boolean insert(@RequestBody XddInstance flwInstance);

    @DeleteMapping("/flow/instance/deleteById/{id}")
    boolean deleteById(@PathVariable("id") Long id);

    @DeleteMapping("/flow/instance/deleteByProcessId/{processId}")
    boolean deleteByProcessId(@PathVariable("processId")Long processId);

    @PutMapping("/flow/instance/updateById")
    boolean updateById(@RequestBody XddInstance instance);

    @GetMapping("/flow/instance/selectCountByParentInstanceId/{parentInstanceId}")
    Long selectCountByParentInstanceId(@PathVariable("parentInstanceId") Long parentInstanceId);

    @GetMapping("/flow/instance/selectById/{id}")
    XddInstance selectById(@PathVariable("id") Long id);

    @GetMapping("/flow/instance/selectByProcessId/{parentInstanceId}")
    Optional<List<XddInstance>> selectListByParentInstanceId(@PathVariable("parentInstanceId") Long parentInstanceId);
}
